package resources;

import java.util.ArrayList;
import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.UriInfo;

import resources.student.DirectionRes;

import dao.Linker;
import dao.StudentDAO;
import model.student.Department;

@Path("/student")
public class StudentRes 
{
	@Context
	UriInfo uriInfo;
	
	@Context
	Request request;
	
	@GET
	@Produces(MediaType.TEXT_XML)
	public List<Department> getDataBrowser() 
	{
		Linker.sort();
		
		List<Department> departments = new ArrayList<Department>();
		departments.addAll( StudentDAO.getDepartmentsCP().values() );
		return departments; 
	}
	
	@GET
	@Produces(MediaType.APPLICATION_JSON)
	public List<Department> getDataBrowserJSON() 
	{
		return getDataBrowser(); 
	}
	
	@GET
	@Produces(MediaType.APPLICATION_XHTML_XML)
	public List<Department> getDataBrowserXHTML() 
	{
		return getDataBrowser(); 
	}
	
	@GET
	@Produces(MediaType.APPLICATION_XML)
	public List<Department> getDataBrowserXML() 
	{
		return getDataBrowser(); 
	}

	@Path("{direction}")
	public DirectionRes getSubData(@PathParam("direction") String id) 
	{
		return new DirectionRes(uriInfo, request, id);
	}
}